<%-- 
    Document   : dealtruocday
    Created on : 03-10-2011, 14:44:46
    Author     : Mr-Nguyen
--%>

<%@page import="DAO.sanphamDAO"%>
<%@page import="DatabasePOJO.sanpham"%>
<%@page import="DAO.linhvucDAO"%>
<%@page import="DatabasePOJO.linhvuc"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<table width="100%" border="0" bgcolor="#CCFFFF">
  <tr>
    <td height="29" ><strong><h3>Deal trước đây</h3></strong></td>
  </tr>
  <tr>
    <td height="118" align="center" valign="middle">
    <form action="" method="post" name="frm1">
    <table width="90%" border="0" background="Images/toong.jpg">
      <tr height="5px">
        <td colspan="3"></td>
        </tr>
      <tr>
        <td width="27%" align="right">Từ khóa:</td>
        <td width="42%"><input type="text" name="txttukhoa" id="txttukhoa" style="width:100%"/></td>
        <td width="31%">&nbsp;</td>
      </tr>
      <tr height="5px">
        <td colspan="3"></td>
        </tr>
      <tr>
        <td align="right">Lĩnh vực:</td>
        <td>
        <select name="cmblinhvuc" id="cmblinhvuc" style="width:100%">
            <option value="-1"> Tất cả </option>>
            <%
            ArrayList<linhvuc> arrlv = linhvucDAO.getListlinhvuc();
            for(int i=0;i<arrlv.size();i++){
%>
<option value="<%= arrlv.get(i).getMaLinhVuc() %>"> <%= arrlv.get(i).getTenLinhVuc() %></option>
<%}%>
        </select>
        </td>
        <td>&nbsp;</td>
      </tr>
      <tr height="5px">
        <td colspan="3"></td>
        </tr>
      <tr>
      <tr>
        <td align="right">Ngày: </td>
        <td><input type="text" name="txtngaytu" id="txtngaytu" style="width:100px"/> 
          --&gt;
          <input type="text" name="txtdenngay" id="txtnagytu" style="width:100px" /></td>
        <td><input type="submit" name="btntim" id="btntim" value="Tìm deal" /></td>
      </tr>
      <tr height="5px">
        <td colspan="3"></td>
        </tr>
    </table>
    </form>
    </td>
  </tr>
  <tr>
    <td height="94" align="center" valign="top">
    <!--bat day san pham truoc day -->
    
    <table width="90%"  border="0" bgcolor="#FFE8E8">
<%
        ArrayList <sanpham> arrsphh = sanphamDAO.getListSanPham(" where ngayhethang > CURRENT_TIMESTAMP");
        int size = arrsphh.size();
        if(size > 10)
            size = 10;
        if(size % 2 != 0)
            size--;
        for(int i=0;i<size;i=i+2){
%>
      <tr>
        <td width="49%" height="242" valign="top">
        <table width="100%" border="0">
          <tr>
              <td height="40" colspan="4" background="Images/toptilte.jpg">
<a href="index.jsp?Action=chitiet&MaSanPham=<%= arrsphh.get(i+1).getMaSanPham() %>"><%= arrsphh.get(i).getTitle().substring(0, 80) %>...</a>
              </td>
            </tr>
          <tr>
            <td colspan="2" align="center" valign="top">
            <table width="100%" height="100%" border="0">
              <tr>
                <td background="Images/backmenu.gif">Giá bán</td>
              </tr>
              <tr>
                <td><%= arrsphh.get(i).getGiaKhuyenMai() %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backngang.gif">Giá bán</td>
              </tr>
              <tr>
                <td style="text-decoration: line-through;"><%= arrsphh.get(i).getGiaBan() %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backngang.jpg">Tiết kiệm</td>
              </tr>
              <tr>
                  <td><%= Integer.parseInt(arrsphh.get(i).getGiaBan()) - Integer.parseInt(arrsphh.get(i).getGiaKhuyenMai()) %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backlogo.gif"><%= arrsphh.get(i).getLuotMua() %> Lược mua</td>
              </tr>
            </table></td>
            <td width="3%">&nbsp;</td>
            <td width="61%" valign="top" align="center" ><img src="Images/<%= arrsphh.get(i).getHinhDaiDien() %>" width="100%" height="200" /></td>
          </tr>
          </table></td>
        <td width="2%" height="242" background="Images/backtable.gif">&nbsp;</td>
        <td width="49%" height="242" valign="top">
        <table width="100%" border="0">
          <tr>
              <td height="40" colspan="4" background="Images/toptilte.jpg">
                  <a href="index.jsp?Action=chitiet&MaSanPham=<%= arrsphh.get(i+1).getMaSanPham() %>"><%= arrsphh.get(i+1).getTitle().substring(0, 80) %>...</a>
              </td>
            </tr>
          <tr>
            <td colspan="2" align="center" valign="top">
            <table width="100%" height="100%" border="0">
              <tr>
                <td background="Images/backmenu.gif">Giá bán</td>
              </tr>
              <tr>
                <td><%= arrsphh.get(i+1).getGiaKhuyenMai() %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backngang.gif">Giá bán</td>
              </tr>
              <tr>
                <td style="text-decoration: line-through;"><%= arrsphh.get(i+1).getGiaBan() %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backngang.jpg">Tiết kiệm</td>
              </tr>
              <tr>
                <td><%= Integer.parseInt(arrsphh.get(i+1).getGiaBan()) - Integer.parseInt(arrsphh.get(i+1).getGiaKhuyenMai()) %>VNĐ</td>
              </tr>
              <tr>
                <td background="Images/backlogo.gif"><%= arrsphh.get(i+1).getLuotMua() %> Lược mua</td>
              </tr>
            </table></td>
            <td width="3%">&nbsp;</td>
            <td width="61%" valign="top" align="center" ><img src="Images/<%= arrsphh.get(i+1).getHinhDaiDien() %>" width="100%" height="200" /></td>
          </tr>
          </table>
        </td>
      </tr>
      <%}%>
    </table>
    
    <!--ket thuc san pham truoc day-->
    </td>
  </tr>
</table>